package com.team11.server.controller.admin;

import com.team11.server.service.admin.Admin_Insert_P_Service;
import com.team11.server.service.admin.Admin_UpdateP_Service;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.CrossOrigin;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.HashMap;

@CrossOrigin
@RestController
@Api(tags = "管理员接口")
public class Admin_UpdateP_Controller {
    @Autowired
    private Admin_UpdateP_Service admin_updateP_service;
    @Autowired
    private Admin_Insert_P_Service admin_insert_p_service;
    @ApiOperation("编辑项目组")
    @PostMapping("/UpdateP")
    public String updateP(String pName, Integer pId, Integer pStatus) {
        HashMap<String, Object> map = new HashMap<>();
        map.put("pName", pName);
        map.put("pId", pId);
        map.put("pStatus", pStatus);
        if ("1".equals(admin_insert_p_service.SelHavePs((String) map.get("pName")))){
            return admin_updateP_service.updateP(map);
        } else return "组名已存在";
    }
}
